package com.qys.livesMall.anchor.controller.sys;

import com.qys.livesMall.anchor.model.dto.lives.sys.UserGradeIntegralRuleDTO;
import com.qys.livesMall.anchor.model.vo.lives.sys.UserGradeIntegralRuleVO;
import com.qys.livesMall.anchor.service.UserGradeIntegralRuleService;
import com.qys.livesMall.common.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2023-09-12
 */
@RestController
@RequestMapping("/sys/userGradeIntegralRule")
@Tag(name = "后台管理-积分规则")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysUserGradeIntegralRuleController {

    private final UserGradeIntegralRuleService userGradeIntegralRuleService;

    @PostMapping("/list")
    @Operation(summary = "积分规则列表")
    public R<List<UserGradeIntegralRuleVO>> list(){
        return R.ok(userGradeIntegralRuleService.UserGradeIntegralRuleList());
    }

    @PostMapping("/add")
    @Operation(summary = "新增积分规则")
    public R<?> add(@RequestBody @Validated UserGradeIntegralRuleDTO userGradeIntegralRuleDTO){
        userGradeIntegralRuleService.addUserGradeIntegralRule(userGradeIntegralRuleDTO);
        return R.ok();
    }

    @PostMapping("/update")
    @Operation(summary = "更新积分规则")
    public R<?> update(@RequestBody @Validated UserGradeIntegralRuleDTO userGradeIntegralRuleDTO){
        userGradeIntegralRuleService.updateUserGradeIntegralRule(userGradeIntegralRuleDTO);
        return R.ok();
    }
}
